class ShellSort:
    def __init__(self, list_):
        self.list_ = list_

    def get_currect_list(self):
        return self.list_

    def ascent_sort(self):
        gap = len(self.list_) // 2 ## //表示向下取整
        while gap > 0:
            for i in range(gap, len(self.list_)):
                position = i
                current_value = self.list_[i]
                while position > 0 and self.list_[position - gap] > current_value:
                    self.list_[position] = self.list_[position - gap]
                    position = position - gap

                self.list_[position] = current_value
            gap = gap // 2
        return self.list_


list_ = ShellSort([4, 6, 8, 2, 9, 3, 7, 5, 1])

print('list', list_.get_currect_list())

list_.ascent_sort()

print('sort result', list_.get_currect_list())
